<template>
    <div class="icons-container">
        <choose-icon @change="copyValue"></choose-icon>
    </div>
</template>

<script>
import ChooseIcon from "@/components/ChooseIcon";
import clipboard from "@/utils/clipboard";

export default {
    name: "Icons",
    components: {
        ChooseIcon,
    },
    methods: {
        copyValue(icon, event) {
            const iconStr = this.generateIcon(icon);
            clipboard(iconStr, event);
        },
        generateIcon({ type, icon }) {
            if (type == "svg") {
                return `<svg-icon icon-class="${icon}" />`;
            } else {
                return `<i class="${icon}" />`;
            }
        },
    },
};
</script>
<style lang="scss" scoped>
.icons-container {
    margin: 10px 20px 0;
    overflow: hidden;

    .grid {
        position: relative;
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    }

    .icon-item {
        margin: 20px;
        height: 85px;
        text-align: center;
        width: 100px;
        float: left;
        font-size: 30px;
        color: #24292e;
        cursor: pointer;
    }

    span {
        display: block;
        font-size: 16px;
        margin-top: 10px;
    }

    .disabled {
        pointer-events: none;
    }
}
</style>
